<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  
  <script>
    let socket = new WebSocket('ws://localhost:8888')
    socket.onopen = function(){
      console.log('连接成功')
      socket.send('服务器你好')
    }
    socket.onmessage = function(event){
      console.log('收到服务器消息' + event.data)
    }
    // socket.on('connect', function(){
    //   console.log('连接成功')
    // })
  </script>
</body>
</html>